<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="white" />
    <title></title>
    <link rel="stylesheet" href="../public/css/weui.css" />
    <link rel="stylesheet" href="../public/css/jquery-weui.css">
    <link rel="stylesheet" href="../public/css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
    <style type="text/css">
    	html,body{
    		height: 100%;
    		display: block;
    	}
    </style>
</head>
<body style="background: #FFFFFF;">
<div id="millshow" style="height: 100%;">
	<div class="millshow-bg">
		<div>
			<div style="height: 1.8rem;"></div>
			<div class="public_top_header">
				<a href="javascript:history.back(-1)" class="weui-cell">
					<div class="weui-cell__hd">
						<img src="../public/images/jiantouleft.png" />
					</div>
					<div class="weui-cell__bd" @click.prevent="jumpdetail()">{{milldetail.name}}</div>
				</a>
			</div>
		</div>
		<div class="mill-msg">
			<div class="millnumber" @click.prevent="jumpdetail()">
				<template v-if="milldetail.mill">
					{{milldetail.mill.name}}
				</template>
			</div>
			<div class="restime">剩余算力天数：{{parseInt(milldetail.hourNum/24)}}天{{milldetail.hourNum%24}}小时</div>
			<div class="strength">算力值<template v-if="milldetail.mill">
					{{milldetail.mill.arithmeticStrength}}
				</template></div>
		</div>
		<img class="wkjmbx" src="../public/images/baoxiang.png"/>
		<div class="a_receive_mine" @click="onkeyshoubi()">一键收矿</div>
		<div class="goldcontainer">
			<div class="item" v-for="(golbs_info,value) in showgold" style="position:relative" >
				<div class="showgolbs" v-for="(item,index) in golbs_info" @click="shoubi(item.id,item.money,value,index)">
					<div  class="golbvalue">{{item.money}}</div>
					<img  src="../public/images/golb.png" style="vertical-align: center"/>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript" src="../public/js/jquery-2.1.4.js"></script>
<script src="../public/js/jquery-weui.js"></script>
<script type="text/javascript" src="../public/js/vue.js" ></script>
<script type="text/javascript" src="../public/js/font_size.js" ></script>
<script type="text/javascript" src="../public/js/common.js" ></script>
<script type="text/javascript">
    $(function(){
    	var millid = getUrlParam('millid');
        var vm = new Vue({
            el:"#millshow",
            data: {
            	milldetail:{
            		
            	},
            	canusegolb:[],
            	indexgolblength:0,
            	showgold:[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]],
				millid:0
            },
            methods:{
				shoubi:function(id,money,value,index){
					AjaxRequest({
	                    url:_url+"/money/mill/incomMill",
	                    data:{
	                    	userid:local.getData("yb_user_info").id,
	                        myMillid :millid,
	                        yunBid:id,
	                        money : money
	                    },
	                    type:"post",
	                    success(res){
	                        if(res.code==1){
	                        	vm.indexgolblength--;
	                        	if(vm.indexgolblength>0){
	                        		harvestersanimationone();
	                        		vm.showgold[value].splice(index,1);
	                        	}else{
	                        		harvestersanimationone();
	                        		vm.refreshlish();
	                        	}
	                        	
	                        }
	                    }
	                });
				},
				onkeyshoubi:function(){
					if(this.canusegolb.length>0){
						AjaxRequest({
		                    url:_url+"/money/mill/onekeyMill",
		                    data:{
		                    	userid:local.getData("yb_user_info").id,
		                        myMillid :millid
		                    },
		                    type:"post",
		                    success(res){
		                        if(res.code==1){
		                        	vm.refreshlish();
		                        	harvestersanimation();
		                        }
		                    }
		                });
					}else{
						$.toast("暂时没有挖出新币，等会儿再来吧！");
					}
					
				},
                jumpdetail(){
				    var millid=getQueryParams(location.href).millid;
				    location.href="./milldetail.html?millid="+millid
				},
				refreshlish:function(){
					AjaxRequest({
	                    url:_url+"/money/mill/findOutputMoney",
	                    data:{
	                        millid:millid
	                    },
	                    type:"post",
	                    success(res){
	                    	vm.canusegolb = res.data;
	                    	vm.indexgolblength = res.data.length;
	                    	vm.showgold = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
	                        for(var i=0;i<res.data.length;i++){
	                        	var numindex = Math.floor(Math.random()*49);
	                        	vm.showgold[numindex].push(res.data[i]);
	                        }
	                    }
	                });
				},

//              ,
//				randomdisplay:function(){
//					var randomdisplaylist = [];
//					for(var i=0;i<this.showgold.length;i++){
//						for(var j=0;j<this.showgold[i].length;j++){
//							var showitems = {};
//							showitems.x = i;
//							showitems.y = j;
//							showitems.num = this.showgold[i][j].num;
//							randomdisplaylist.push(showitems);
//						}
//					}
//					randomdisplaylist = randomdisplaylist.sort(compare('num'));
//					for(var h=0;h<randomdisplaylist.length;h++){
//						if(h<30){
//							this.showgold[randomdisplaylist[h].x][randomdisplaylist[h].y].isshow = true;
//						}else{
//							this.showgold[randomdisplaylist[h].x][randomdisplaylist[h].y].isshow = false;
//						}
//					}
//				}
            },
            created:function(){
                AjaxRequest({
                    url:_url+"/money/mill/mymilldetail",
                    data:{
                        millid:millid
                    },
                    type:"post",
                    load:true,
                    success(res){
                        if(isReqSucceed(res)){
							vm.milldetail=res.data;
							AjaxRequest({
			                    url:_url+"/money/mill/findOutputMoney",
			                    data:{
			                        millid:millid
			                    },
			                    type:"post",
			                    load:true,
			                    success(res){
			                    	vm.canusegolb = res.data;
			                    	vm.indexgolblength = res.data.length;
			                        for(var i=0;i<res.data.length;i++){
			                        	var numindex = Math.floor(Math.random()*49);
			                        	vm.showgold[numindex].push(res.data[i]);
			                        }
			                    }
			                });
						}
                    }
                });
            }
        })
    })
    function harvestersanimationone(){
		var html = '<div class="harvestersanimationone" style="position: fixed;width: 100%;max-width: 750px;top: 0;bottom: 0;z-index: 9999;">'+
					'<img style="width: 100%;" src="../public/images/onecoin.gif" /></div>';
		$("body").append(html);
		setTimeout(function(){
			$(".harvestersanimationone").remove();
		},1600)
	}
</script>
</body>
</html>



